use serde::{Serialize, Deserialize};


/// 定义 服务器 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Framework {
    pub datasource: Datasource,
    pub redis: Redis,
    pub cache: Cache,
    pub logging: Logging,
    pub docs: Docs,
}


/// 定义 数据库 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Datasource {
    pub url: Option<String>,
    pub username: String,
    pub password: String,
    pub host: String,
    pub port: u16,
    pub database: String,
    pub db_pool: DbPool,

}

/// 定义 连接池 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DbPool {
    pub pool_pre_ping: bool,
    pub pool_size: u8,
    pub pool_timeout: u64,
    pub echo: bool,
}

/// 定义 Redis 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Redis {
    pub host: String,
    pub port: u16,
    pub password: Option<String>,
    pub timeout: Option<String>,
    pub database: Option<u8>,
}

/// 定义 连接类型 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Cache {
    pub enable_type: String,
}


/// 定义 日志 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Logging {
    pub path: String,
    pub level_root: String,
}

/// 定义 文档 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Docs {
    pub swagger_ui: SwaggerUi,
    pub enabled: bool,
    pub packages_to_scan: String,
    pub paths_to_match: String,
}

/// 定义 文档 配置结构体
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SwaggerUi {
    pub enabled: bool,
    pub path: String,
}

